package czy.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.Contact;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

/*  swagger文档页面swagger-ui */
@EnableSwagger2
@Configuration
public class SpringSwaggerConfig {

    private static final String NAME = "crayon-shin-chan";
    private static final String URL = "https://github.com/crayon-shin-chan";
    private static final String EMAIL = "1253665625@qq.com";
    private static final String VERSION = "1.0";
    private static final String LICENSE = "Apache License";


    /* API信息 */
    private static ApiInfo apiInfo(String title) {
        Contact contact = new Contact(NAME,URL,EMAIL);
        return new ApiInfoBuilder()
                /* API标题 */
                .title(title)
                /* 版本 */
                .version(VERSION)
                /* 许可 */
                .license(LICENSE)
                .contact(contact)
                .build();
    }

    /* 历史流程实例和历史任务、历史活动管理 */
    @Bean
    public Docket historyDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo("消息发送"))
                .select()
                .apis(RequestHandlerSelectors.basePackage("czy.demo.controller"))
                .paths(PathSelectors.any())
                .build();
    }



}
